<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>后台管理</title>
  <link rel="stylesheet" href="css/login.css">
    <script src="js/jquery1.42.min.js"></script>
</head>
<body class="login-bg">
<script>
				
 function checklogin(){  
	  //获取手机号码
	  let name=$("#username").val();
	  //获取密码
	  let pwd=$("#password").val(); 
	  //获取验证码
	  let rand=$("#mrand").val();
	  //发起ajax请求，
	  $.ajax({
		url:"checkrand.do",
		type:"GET",
		data:{rand:rand},
		dataType:"text",
		success:function(msg){
			
			//验证码匹配
           if(msg==1){
        	   $.ajax({
        			url:"Login.do",
        			type:"GET",
        			data:{name:name,pwd:pwd},
        			dataType:"text",
        			success:function(msg){	
        				//手机号码和密码正确
        	             if(msg==1){
        	            	 alert("登录成功");
        	            	 location.href="index.jsp";
        	            	//手机号码和密码不正确
        	             }else if(msg==0){
        	            	 alert("用户名或者密码错误");
        	             }else if(msg==2){
        	                 alert("盗链狗滚！！！！")
                         }
        			}
        		  });
           }else{
        	   alert("验证码错误")
           }
		}
	  })
	  
	 
 }
 
 </script>
    <div class="login">
        <div class="message">系统登录</div>
        <div id="darkbannerwrap"></div>   
        <form method="get" class="layui-form" >
            <input id="username" placeholder="用户名"  type="text" >
            <hr class="hr15">
            <input id="password"  placeholder="密码"  type="password" >
            <hr class="hr15">
            <div>
            <input id="mrand"  placeholder="验证码  " type="text"style="width: 340px;display: inline-block;" >
            <span style="margin-left:-100px; height: 50px"> <img src="images/image.jsp" onclick="this.src='images/image.jsp?id='+Math.random()""></span></div>
            <hr class="hr15">
            <button type="button" 
								style="height: 48px; border-radius: 50px;width: 346px ;background: #2fb9d4" onclick="checklogin()"> 登录</button>
            <hr class="hr20" >
        </form>
    </div>
  <script>
           

        </script>

    
    <!-- 底部结束 -->
    
</body>
</html>